package com.ruoyi.file.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import com.ruoyi.file.service.ISysFileService;

/**
 * 文件存储方式配置
 *
 * @author ruoyi
 */
@Configuration
public class FileStorageConfig
{
    @Value("${file.storage:local}")
    private String storageType;

    @Bean
    @Primary
    public ISysFileService sysFileService(
            @Qualifier("localSysFileServiceImpl") ISysFileService localSysFileService,
            @Qualifier("minioSysFileServiceImpl") ISysFileService minioSysFileService,
            @Qualifier("fastDfsSysFileServiceImpl") ISysFileService fastDfsSysFileService,
            @Qualifier("ossSysFileServiceImpl") ISysFileService ossSysFileService)
    {
        switch (storageType.toLowerCase())
        {
            case "minio":
                return minioSysFileService;
            case "fastdfs":
                return fastDfsSysFileService;
            case "oss":
                return ossSysFileService;
            case "local":
            default:
                return localSysFileService;
        }
    }
}
